package com.example.cardmatchinggame;

public class Card {
    private String content;
    private boolean isFaceUp;
    private boolean isMatched;

    public Card(String content) {
        this.content = content;
        this.isFaceUp = false;
        this.isMatched = false;
    }

    public String getContent() {
        return content;
    }

    public boolean isFaceUp() {
        return isFaceUp;
    }

    public void setFaceUp(boolean faceUp) {
        isFaceUp = faceUp;
    }

    public boolean isMatched() {
        return isMatched;
    }

    public void setMatched(boolean matched) {
        isMatched = matched;
    }

    // 匹配方法：用于双卡模式
    public int match(Card otherCard) {
        int score = 0;
        if (this.content.equals(otherCard.getContent())) {
            score = 4;
            this.isMatched = true;
            otherCard.setMatched(true);
        } else {
            score = -1;
        }
        return score;
    }

    // 匹配方法：用于三卡模式
    public int match(Card card1, Card card2) {
        int score = 0;
        if (this.content.equals(card1.getContent()) && 
            this.content.equals(card2.getContent())) {
            score = 12;
            this.isMatched = true;
            card1.setMatched(true);
            card2.setMatched(true);
        } else {
            score = -2;
        }
        return score;
    }
}
